package com.ruoyi.project.system.login.domain;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import org.apache.shiro.crypto.SecureRandomNumberGenerator;


@Data
@AllArgsConstructor
@NoArgsConstructor
public class MiniSysUser {
    /** 用户ID */
    private Long userId;

    /** 登录名称 */
    private String loginName;

    /** 密码 */
    private String password;

    /** 盐加密 */
    private String salt;


    /**
     * 生成随机盐
     */
    public void randomSalt()
    {
        // 一个Byte占两个字节，此处生成的3字节，字符串长度为6
        SecureRandomNumberGenerator secureRandom = new SecureRandomNumberGenerator();
        String hex = secureRandom.nextBytes(3).toHex();
        setSalt(hex);
    }





}
